/**
 * @author :    hippo
 * @date :      2023-08-03
 * @copyright   Apache 2.0
*/

#ifndef _EPOLLER_H
#define _EPOLLER_H

#include <sys/epoll.h>
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include <vector>
#include <errno.h>

class Epoller {
private:
    int epoll_fd_;
    std::vector<struct epoll_event> events_;
public:
    explicit Epoller(int max_event = 1024);
    ~Epoller();
    bool AddFd(int fd, uint32_t events);
    bool ModFd(int fd, uint32_t events);
    bool DelFd(int fd);
    int Wait(int timeout_ms = -1);
    int GetEventFd(size_t i) const;
    uint32_t GetEvents(size_t i) const;
};

#endif // _EPOLLER_H